; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=jump-threading -verify-each -mtriple=x86_64-- < %s | FileCheck %s

define void @foo() {
; CHECK-LABEL: @foo(
; CHECK-NEXT:  B:
; CHECK-NEXT:    [[Z:%.*]] = add i32 undef, 1
; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32 [[Z]], 0
; CHECK-NEXT:    br i1 [[CMP]], label [[EXIT:%.*]], label [[B_THREAD:%.*]]
; CHECK:       B.thread:
; CHECK-NEXT:    br label [[EXIT]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  br i1 false, label %A, label %B

A:
  %x = phi i32 [ undef, %entry ], [ %z, %B ]
  br label %B

B:
  %y = phi i32 [ undef, %entry ], [ %x, %A ]
  %z = add i32 %y, 1
  %cmp = icmp ne i32 %z, 0
  br i1 %cmp, label %exit, label %A

exit:
  ret void
}
